// Longest Palindrome Subsequence

#include<iostream>
using namespace std;

char s[] = "abcydefexdcbay";
int l[sizeof(s)/sizeof(char)][sizeof(s)/sizeof(char)];
int pl();
int pl(int i, int j);

int main()
{
	cout << "\n" << pl() << "\n";
	return 0;
}

int pl()
{
	for(int i=0; i<sizeof(s); i++)
	{
		for(int j=0; j<sizeof(s); j++)
		l[i][j] = -1;
	}
	return pl(0,sizeof(s)/sizeof(char)-1);
}

int pl(int i, int j)
{
	if(l[i][j]!=-1)
	return l[i][j];
	
	if(i==j)
	return 1;
	
	if(i>j)
	return 0;
	
	if(s[i]==s[j])
	{
		l[i][j] = pl(i+1,j-1) +2;
		return l[i][j];
	}
	
	l[i][j] = max( pl(i+1,j), pl(i,j-1));
	return l[i][j];
}
	
